package com.elephant.controller;

import com.elephant.pojo.Weather;
import com.elephant.service.WeatherJsonService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.util.List;

@Controller
public class WeatherController {

    @RequestMapping("/weather")
    public String getWeather(String city, Model model) throws IOException {
        WeatherJsonService weatherJsonService = new WeatherJsonService();

        List<Weather> weathers = weatherJsonService.getWeatherInfo(city);

        model.addAttribute("weathers",weathers);

        return "weather";
    }
}
